var t = require("../../../../@babel/runtime/helpers/objectSpread2"), e = require("../../../../@babel/runtime/helpers/typeof"), a = require("../../../../@babel/runtime/helpers/defineProperty"), n = getApp(), r = "0", i = !1, s = !1;

Page({
    data: a({
        language: "",
        is_first_content: !1,
        is_second_content: !1,
        mailLanguage: "",
        mailFullReturnTitle: "",
        mailFullReturnName: "",
        activeName: "first",
        activeName1: "0",
        first_content: [],
        second_content: [],
        alreadyReturn: 0,
        each_return_rate: 0,
        order_return_rate: 0,
        returnAmountTotal: 0,
        totay: "0",
        valid: "0",
        task: !1,
        notReturn: 0,
        fullReturnName: "",
        isShow: !1,
        return_list_name: "",
        httpUrl: n.getNetAddresss("plugin.single-return.api.single-return.get-single-return-queue"),
        loading: !1,
        logPage: 1,
        isLoadMore: !1,
        noMore: !1
    }, "logPage", 1),
    onLoad: function(t) {
        this.checkrouter(), this.initMailLanguage(), this.getData(), this.getListData();
    },
    checkrouter: function() {
        try {
            var t = function() {
                for (var t = wx.getStorageSync("yz_basic_info"), e = t.popularize_page.mini.vue_route, a = 0; a < e.length; a++) if ("single_return_center" == e[a]) return console.log(t.popularize_page.mini.mini_url + "跳转的路径"), 
                wx.showToast({
                    title: "未开启推广权限",
                    duration: 1e3,
                    icon: "none",
                    success: function() {
                        setTimeout(function() {
                            wx.redirectTo({
                                url: t.popularize_page.mini.mini_url
                            });
                        }, 1e3);
                    }
                }), {
                    v: void 0
                };
            }();
            if ("object" === e(t)) return t.v;
        } catch (t) {
            console.log(t);
        }
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore && this.getMoreData();
    },
    onShareAppMessage: function() {},
    initMailLanguage: function() {
        var t, e = this, a = n.getNetAddresss("setting.get-lang-setting");
        n._getNetWork({
            url: a,
            success: function(a) {
                var r = a.data;
                if (1 === r.result) {
                    t = r.data;
                    var i = n.setMailLanguage("消费赠送", t.single_return.single_return), s = n.setMailLanguage("赠送", t.single_return.return_name), o = n.setMailLanguage("消费队列", t.single_return.return_queue), u = n.setMailLanguage("消费记录", t.single_return.return_log);
                    e.setData({
                        mailSingleReturnTitle: i,
                        mailSingleReturnName: s,
                        mailReturnQueue: o,
                        mailReturnLog: u
                    });
                } else wx.showToast({
                    title: r.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getData: function() {
        var t = this, e = n.getNetAddresss("plugin.single-return.api.single-return.get-single-return-statistic");
        n._getNetWork({
            url: e,
            success: function(e) {
                var a = e.data, r = a.data, i = a.result, s = a.msg;
                1 === i ? t.setData({
                    alreadyReturn: r.alreadyReturn,
                    each_return_rate: r.each_return_rate,
                    order_return_rate: r.order_return_rate,
                    returnAmountTotal: r.returnAmountTotal,
                    notReturn: r.notReturn,
                    totay: r.totay,
                    valid: r.valid,
                    task: r.task
                }) : n.tips(s);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    toReturnInfo: function(t) {
        var e = t.currentTarget.dataset.id || t.target.dataset.id;
        wx.navigateTo({
            url: "/packageB/member/income/single_return_list_info/single_return_list_info?id=" + e
        });
    },
    getReturnList: function() {
        var t = this, e = n.getNetAddresss("plugin.single-return.api.single-return.get-single-return-queue");
        n._getNetWork({
            url: e,
            success: function(e) {
                var a = e.data;
                1 === a.result ? t.setData({
                    first_content: a.data
                }) : wx.showToast({
                    title: a.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getReturnListInfo: function() {
        var t = this, e = n.getNetAddresss("plugin.single-return.api.single-return.get-single-return-log");
        n._getNetWork({
            url: e,
            success: function(e) {
                var a = e.data;
                1 === a.result ? t.setData({
                    second_content: a.data
                }) : wx.showToast({
                    title: a.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    setDataByTabIndex: function() {
        "0" != r || i ? "1" != r || s || (s = !0, this.getReturnListInfo()) : (i = !0, this.getReturnList());
    },
    handleClick1: function(t) {
        var e = t.detail.name;
        if (e == this.data.activeName1) return !1;
        this.setData({
            activeName1: e,
            listData: [],
            logPage: 1
        }), this.getListData();
    },
    handleClick: function(t) {
        var e = t.detail.name;
        if (e == this.data.avtiveName) return !1;
        var a = n.getNetAddresss("plugin.single-return.api.single-return.get-single-return-log");
        return "first" == e && (a = n.getNetAddresss("plugin.single-return.api.single-return.get-single-return-queue")), 
        this.setData({
            logPage: 1,
            listData: [],
            httpUrl: a,
            activeName: e
        }), this.getListData(), !1;
    },
    getJson: function() {
        return "first" == this.data.activeName ? {} : {
            award_status: this.data.activeName1
        };
    },
    setnoMore: function(t) {
        this.setData({
            noMore: t,
            isLoadMore: !t
        });
    },
    getListData: function() {
        var e = this;
        this.setData({
            loading: !0
        }), n._postNetWork({
            url: this.data.httpUrl,
            data: t({
                page: 1
            }, this.getJson()),
            success: function(t) {
                var a = t.data, r = a.result, i = a.msg, s = a.data;
                e.setData({
                    loading: !1
                }), 1 == r ? (e.setData({
                    listData: s.data
                }), e.setnoMore(e.data.logPage == s.last_page)) : n.tips(i);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var e = this;
        this.setData({
            loading: !0
        }), n._postNetWork({
            url: this.data.httpUrl,
            data: t({
                page: 1
            }, this.getJson()),
            success: function(t) {
                var a = t.data, r = a.result, i = a.msg, s = a.data;
                e.setData({
                    loading: !1
                }), 1 == r ? (e.setData({
                    listData: e.data.listData.concat(s.data)
                }), e.setnoMore(e.data.logPage == s.last_page)) : n.tips(i);
            }
        });
    }
});